<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of frontController
 *
 * @author drarko
 */
class frontController 
{
    public $clase;
    public $uri;
    
    public function __construct($path)
    {
        $this->path = $path;

        $this->uri = $this->path[1];
        
        if($this->path[1] == "")
        {
            $this->uri = "index";
        }
        
        $this->clase = $this->uri;
        
        date_default_timezone_set("America/Argentina/Buenos_Aires");
        
        foreach($this->path as $key => $value)
        {
            if($key == 0)
            {

            }elseif($key == 1)
            {
              
            }else{
                if(($key % 2) == 0)
                {
                    $_GET[$value] = $this->path[$key + 1];
                }elseif(($key % 2) == 1)
                {
                    
                }
            }
        }
        
     }
     
     public function show()
     {
         
        if((isset($_SESSION['logged']))||($this->clase == "login"))
        { 
            $clase = $this->clase;
            if($_POST)         
                $clase = new $clase("post");
            elseif($_GET)
                $clase = new $clase("post");
            else
                $clase = new $clase();            
            
        }
        else
        {
            $clase = new login();
        }
        
        return $clase->preShow();
         
     }
    
}

